/* eslint-disable */
import axios from 'axios'
import qs from 'qs'
import router from '../router/router';

axios.defaults.timeout = 10000;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
axios.defaults.baseURL = 'http://www.zhenxc.com/feesys/';

axios.interceptors.request.use(function (config) {
  if (config.method && config.method.toLocaleLowerCase() === 'post') {
    if (config.data) {
      /*处理参数，防止参数引起的跨域访问限制*/
      config.data = qs.stringify(config.data)
    }
  }
  return config;
}, function (error) {
  return Promise.reject(error);
});

axios.interceptors.response.use(function (response) {
    if (response.data && response.data.resultCode != undefined && response.data.resultCode == 22) {
      console.log("openid" + localStorage.getItem("openid"));
      router.push({
        path: '/Error'
      })
    }
    return response;
  }, function (error) {
    return Promise.reject(error);
  }
);
export default axios;
